home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRCMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  574 b   |  28 lines

  1. /* strcmp.c From TC Bible page 276  Use strcmp to compare one string
  2. to another.  The comparision is case sensitive. */
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. main()
  7. {
  8.     int result;
  9.     char str1[80], str2[80];
  10.     printf("Enter a string: ");
  11.     gets(str1);
  12.     printf("Enter a string to compare with first: ");
  13.     gets(str2);
  14.     result = strcmp(str1, str2);
  15.     if (result == 0)
  16.     {
  17.         printf("\"%s\" == \"%s\"\n", str1, str2);
  18.     }
  19.     if (result < 0)
  20.     {
  21.         printf("\"%s\" < \"%s\"\n", str1, str2);
  22.     }
  23.     if (result > 0)
  24.     {
  25.         printf("\"%s\" > \"%s\"\n", str1, str2);
  26.     }
  27. }
  28.